/**
 * Created with IntelliJ IDEA.
 * Description:leedcode.简单题.至少是其他数字两倍的最大数
 */

class Solution {
    public int dominantIndex(int[] nums) {
        int max = 0;
        int nmax = 0;
        for(int i = 0; i < nums.length; i++){
            if(nums[max] < nums[i]){
                nmax = max;
                max = i;
            }
            if(nums[nmax] == nums[max] && nums.length > 1){
                nmax = max + 1;
            }
            if(nums[nmax] < nums[i] && max != i){
                nmax = i;
            }
        }
        if(nums[max] >= nums[nmax] * 2){
            return max;
        }else{
            return -1;
        }
    }
}

public class Test {
}
